<?php

require_once(SRC_PATH."Object/Hostname.php");
require_once("GenericReader.php");

class HostnameReader extends GenericReader{
		
	public function __construct($object = NULL, $connection = NULL){
		parent::__construct($object, $connection);
	}
	
	public function execute(){
		$this->select = new RXSelect($this->connection);
		
		switch($this->operation){
			default:
				return $this->executeGetOne();			
		}
	}
	
	public function executeGetOne(){
		$this->select->addTable("hostname");
		$this->select->addWhereAndStatementEquals("id", $this->object->getId());
		return $this->select->execute();
	}
	
	public function next(){
		$row = $this->select->next();
		if($row){
			return new Hostname(	$row["id"], 
													$row["hostname"], 
													$row["visits"]);
		}else{
			return FALSE;
		}
	}
}